package com.example.demo.dto;

import java.util.*;

public class PaginationDTO {
    private boolean showPrevious;
    private boolean showFirstPage;
    private boolean showNext;
    private boolean showEndPage;
    private Integer page;
    private List<QuestionDTO> questions;
    private List<Integer> pages=new ArrayList<>();
    private Integer totalPage;

    public void setPagination(Integer totalPage,Integer page) {
        this.totalPage=totalPage;
        this.page=page;
        pages.add(page);

        for(int i=1;i<=3;i++){
            if(page-i>0){
                pages.add(0,page-i);
            }
            if(page+i<=totalPage){
                pages.add(page+i);
            }
        }


        if(page==1){
            showPrevious=false;
        }else {
            showPrevious=true;
        }


        if(page==totalPage){
            showNext=false;
        }else {
            showNext=true;
        }


        if(pages.contains(1)){
            showFirstPage=false;
        }else {
            showFirstPage=true;
        }


        if(pages.contains(totalPage)){
            showEndPage=false;
        }else {
            showEndPage=true;
        }
    }


    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public List<QuestionDTO> getQuestions() {
        return questions;
    }

    public void setQuestions(List<QuestionDTO> questions) {
        this.questions = questions;
    }

        public boolean isEmpty() {
            return false;
        }


        public boolean contains(Object o) {
            return false;
        }

        public Iterator<Integer> iterator() {
            return null;
        }

        public Object[] toArray() {
            return new Object[0];
        }

        public <T> T[] toArray(T[] a) {
            return null;
        }

        public boolean add(Integer integer) {
            return false;
        }

        public boolean remove(Object o) {
            return false;
        }

        public boolean containsAll(Collection<?> c) {
            return false;
        }

        public boolean addAll(Collection<? extends Integer> c) {
            return false;
        }

        public boolean addAll(int index, Collection<? extends Integer> c) {
            return false;
        }

        public boolean removeAll(Collection<?> c) {
            return false;
        }

        public boolean retainAll(Collection<?> c) {
            return false;
        }

        public void clear() {

        }

        public Integer get(int index) {
            return null;
        }


        public Integer set(int index, Integer element) {
            return null;
        }

        public void add(int index, Integer element) {

        }

        public Integer remove(int index) {
            return null;
        }

        public int indexOf(Object o) {
            return 0;
        }

        public int lastIndexOf(Object o) {
            return 0;
        }

        public ListIterator<Integer> listIterator() {
            return null;
        }

        public ListIterator<Integer> listIterator(int index) {
            return null;
        }

        public List<Integer> subList(int fromIndex, int toIndex) {
            return null;
        }

    public boolean isShowPrevious() {
        return showPrevious;
    }

    public void setShowPrevious(boolean showPrevious) {
        this.showPrevious = showPrevious;
    }

    public boolean isShowFirstPage() {
        return showFirstPage;
    }

    public void setShowFirstPage(boolean showFirstPage) {
        this.showFirstPage = showFirstPage;
    }

    public boolean isShowNext() {
        return showNext;
    }

    public void setShowNext(boolean showNext) {
        this.showNext = showNext;
    }

    public boolean isShowEndPage() {
        return showEndPage;
    }

    public void setShowEndPage(boolean showEndPage) {
        this.showEndPage = showEndPage;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public List<QuestionDTO> getQuestion() {
        return questions;
    }

    public void setQuestion(List<QuestionDTO> question) {
        this.questions = question;
    }

    public List<Integer> getPages() {
        return pages;
    }

    public void setPages(List<Integer> pages) {
        this.pages = pages;
    }
};

